package trong.gold.soft.com.model;
import javax.microedition.media.*;
public class mediaGame {
	private Player backgroundPlayer = null;
	public mediaGame(boolean b,String s){
		try{
			 backgroundPlayer = Manager.createPlayer(getClass().getResourceAsStream("/com/audio/" + s),"audio/Midi");
		 }catch(Exception e){
			 
		 }
		if(b){
			try{
				  backgroundPlayer.prefetch();
			      backgroundPlayer.setLoopCount(-1);
			 }catch(Exception e){
				 
			 }
		}
	}
	public void startMedia(){
		try {
	        if (backgroundPlayer != null) {
	          backgroundPlayer.start();
	        }
	      } catch (Exception e) {
	        e.printStackTrace();
	      }
	}
	public void stopMedia(){
		try {
	        if (backgroundPlayer != null) {
	          backgroundPlayer.stop();
	        }
	      } catch (Exception e) {
	        e.printStackTrace();
	      }
	}
	public void closeMedia(){
		try {
	        if (backgroundPlayer != null) {
	          backgroundPlayer.close();
	        }
	      } catch (Exception e) {
	        e.printStackTrace();
	      
	      }
	}
}
